#include <bits/stdc++.h>
#include <iostream>
using namespace std;

const int N = 510;
int arr[N][N];
int vis[N][N];

int dx[2] = { 0, 1 };
int dy[2] = { 1, 0 };


int n, m;
int ans;


void dfs(int x, int y, int sum)
{
    if (x >= n || x < 0 || y >= m || y < 0)
        return;

    if (x == n - 1 && y == m - 1)
    {
        ans = max(ans, sum);
        return;
    }

    for (int i = 0; i < 2; i++)
    {
        int x1 = x + dx[i];
        int y1 = y + dy[i];

        if (x1 >= 0 && x1 < n && y1 >= 0 && y1 < m && vis[x1][y1] == 0)
        {
            vis[x1][y1] = 1;
            dfs(x1, y1, sum + arr[x1][y1]);
            vis[x1][y1] = 0;

        }
    }
}

int main() {

    cin >> n >> m;

    string str;
    for (int i = 0; i < n; i++)
    {
        cin >> str;
        for (int j = 0; j < m; j++)
        {
            if (str[j] == 'l')
                arr[i][j] = 4;
            else if (str[j] == 'o')
                arr[i][j] = 3;
            else if (str[j] == 'v')
                arr[i][j] = 2;
            else if (str[j] == 'e')
                arr[i][j] = 1;
            else
                arr[i][j] = 0;
        }
    }

    // for (int i = 0; i < n; i ++)
    // {
    //     for (int j = 0; j < m; j ++)
    //         cout << arr[i][j] << " ";

    //     cout << endl;
    // }

    // int ans = 0, sum = arr[0][0];
    // queue<pair<int, int>> que;
    // que.push({0, 0}); 

    // while (!que.empty())
    // {
    // }

    dfs(0, 0, arr[0][0]);

    cout << ans << endl;

    return 0;

}
